from django.db import models

class StudyMaterial(models.Model):
    MATERIAL_TYPES = [
        ('notes', '学习笔记'),
        ('video', '视频课程'),
        ('past_paper', '历年真题'),
        ('admission', '招生简介'),
        ('syllabus', '考试大纲'),
    ]
    
    name = models.CharField('资料名称', max_length=100)
    description = models.TextField('简介', blank=True)
    key = models.CharField(verbose_name='文件存储在cos中的key', max_length=128, null=True, blank=True)
    file_size = models.BigIntegerField(verbose_name='文件大小', null=True, blank=True, help_text='字节')
    file_path = models.CharField(verbose_name='文件路径', max_length=256, null=True, blank=True)
    download_count = models.PositiveIntegerField('下载次数', default=0)
    upload_time = models.DateTimeField('上传时间', auto_now_add=True)
    material_type = models.CharField(
        '资料类型', 
        max_length=20, 
        choices=MATERIAL_TYPES
    )

    class Meta:
        verbose_name = '考研资料'
        verbose_name_plural = '考研资料'

    def __str__(self):
        return self.name
